<?php

class articleTable extends myDoctrineIndexedTable
{
	public static function getInstance()
	{
		return Doctrine_Core::getTable('article');
	}
	/**
	 * Get new active articles
	 */
	public function newActiveArticles()
	{
		return $this->createQuery()->where('is_active', 1)->orderBy("id DESC");
	}
	/**
	 * Get top active articles
	 */
	public function topActiveArticles()
	{
		return $this->createQuery()->where('is_active', 1);
	}
	/**
	 * Get law active articles
	 */
	public function lawActiveArticles()
	{
		return $this->createQuery()
		  ->where('is_active', 1)
		  ->andWhere("is_law", 1);
	}
	/**
	 * Get normative active articles
	 */
	public function normativeActiveArticles()
	{
		return $this->createQuery()
		  ->where('is_active', 1)
		  ->andWhere("is_normative", 1);
	}
	/**
	 * Method to get article example
	 */
	public function getArticleExample($id = null)
	{
		return $this->createQuery()
		  ->where("is_active", 1)
		  ->addWhere("id", $id)
		  ->fetchOne(Doctrine_Core::HYDRATE_RECORD);
	}
}